home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9436 < prev    next >
Encoding:
Text File  |  1996-08-05  |  985 b   |  50 lines

  1. Newsgroups: comp.lang.c
  2. Path: bear.wn.bawue.de!jo
  3. From: jo@bear.wn.bawue.de (Joerg Sommrey)
  4. Subject: Re: What is the correct behaviour ?
  5. Message-ID: <Do1uu2.ABM@bear.wn.bawue.de>
  6. Organization: private
  7. Date: Sun, 10 Mar 1996 11:34:49 GMT
  8. References: <1996Mar9.130223.1400@paramount.nikhefk.nikhef.nl>
  9.  
  10. In <1996Mar9.130223.1400@paramount.nikhefk.nikhef.nl> bouvere@paramount.nikhefk.nikhef.nl (Ferdinand de Bouvere) writes:
  11.  
  12. >Trying this code on 3 platforms:
  13.  
  14. [...]
  15.  
  16. >Linux gcc: OK
  17. >result: 123
  18.  
  19. That's strange:
  20.  
  21. ~/tmp$ cat ctest.c
  22. #include <stdio.h>
  23. int a = 0;
  24. int main(void)
  25. {
  26.     int a = 123;
  27.     {
  28.     extern int a;
  29.     printf("%d\n", a);
  30.     }
  31.     return 0;
  32. }
  33.  
  34. ~/tmp$ make ctest
  35. gcc -m486 -O2 -Wall -ansi -pedantic    ctest.c   -o ctest
  36. ctest.c: In function `main':
  37. ctest.c:5: warning: unused variable `a'
  38.  
  39. ~/tmp$ ./ctest 
  40. 0
  41.  
  42. ~/tmp$ gcc --version
  43. 2.5.8
  44.  
  45. This is - as already stated - the correct result.
  46.  
  47. -Jo
  48. -- 
  49. -rw-r--r--   1 jo       users          75 Mar 10 11:06 /home/jo/.signature
  50.